﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <link href="~/Content/css/bootstrap.min.css" rel="stylesheet" />
    <script src="~/Scripts/js/jquery.min.js"></script>
    <script src="~/Scripts/js/bootstrap.min.js"></script>
    <title>Leader</title>
</head>
<body>
    <div id="div">
        <br />

        <input id="Hidden1" type="hidden" value="@ViewBag.pid" /><h2>Personnel Examine And Approve</h2><input id="Hidden2" type="hidden" value="@ViewBag.did" />

        
    </div>
</body>
</html>
<script>
    $(function () {
        var PositionID = $("#Hidden1").val();
        var DeptID = $("#Hidden2").val();
     
            $.ajax({
                url: "/ModiFication/yici",
                data: { PositionID: PositionID, DeptID: DeptID },
                success: function (obj) {
                    obj = JSON.parse(obj);
                    alert(obj)
                    for (var i = 0; i < obj.length; i++) {
                        var s = "";
                        s += '<table id="t1" class="table-bordered table table-condensed table-responsive">';
                        s += '<thead>'
                        s += '<tr><td>员工编号</td><td>员工姓名</td><td>变更状态</td><td>变更职位</td><td>变更部门</td><td>申请时间</td><td>申请理由</td><td>操作</td></tr></thead>';
                        s += '<tbody>'
                        for (var i = 0; i < obj.length; i++) {
                            if (obj[i].ChangeStatu == 1) {
                                s += '<tr><td>' + obj[i].EmployID + '</td><td>' + obj[i].EmployName + '</td><td>晋升申请</td><td>' + obj[i].PositionName + '</td><td>' + obj[i].DeptName + '</td><td>' + obj[i].Change_time + '</td><td>' + obj[i].Change_Reason + '</td><td><input id="Button1" type="button" value="同意" onclick="funtong(' + obj[i].Situation_id + ')" /><input id="Button1" type="button" value="不同意" onclick="funbutong(' + obj[i].Situation_id + ')" /></td></tr>'
                            }
                            else {
                                s += '<tr><td>' + obj[i].EmployID + '</td><td>' + obj[i].EmployName + '</td><td>降级申请</td><td>' + obj[i].PositionName + '</td><td>' + obj[i].DeptName + '</td><td>' + obj[i].Change_time + '</td><td>' + obj[i].Change_Reason + '</td><td><input id="Button1" type="button" value="同意" onclick="funtong(' + obj[i].Situation_id + ')" /><input id="Button1" type="button" value="不同意" onclick="funbutong(' + obj[i].Situation_id + ')" /></td></tr>'
                            }
                        }
                    }
                    s += '</tbody>'
                    s += '</table>'
                    $("#div").html(s);
                }
            })
        
    })
    //$(function () {
    //    var PositionID = $("#Hidden1").val();
    //    var DeptID = $("#Hidden2").val();
      
    //    $.ajax({
    //        url: "/ModiFication/erci",
    //        data: { PositionID: PositionID, DeptID: DeptID },
    //        success: function (obj) {
    //            obj = JSON.parse(obj);
    //            alert(obj)
    //            for (var i = 0; i < obj.length; i++) {
    //                var s = "";
    //                s += '<table id="t1" class="table-bordered table table-condensed table-responsive">';
    //                s += '<thead>'
    //                s += '<tr><td>员工编号</td><td>员工姓名</td><td>变更状态</td><td>变更职位</td><td>变更部门</td><td>申请时间</td><td>申请理由</td><td>操作</td></tr></thead>';
    //                s += '<tbody>'
    //                for (var i = 0; i < obj.length; i++) {
    //                    if (obj[i].ChangeStatu == 1) {
    //                        s += '<tr><td>' + obj[i].EmployID + '</td><td>' + obj[i].EmployName + '</td><td>晋升申请</td><td>' + obj[i].PositionName + '</td><td>' + obj[i].DeptName + '</td><td>' + obj[i].Change_time + '</td><td>' + obj[i].Change_Reason + '</td><td><input id="Button1" type="button" value="同意" onclick="funtong(' + obj[i].Situation_id + ')" /><input id="Button1" type="button" value="不同意" onclick="funbutong(' + obj[i].Situation_id + ')" /></td></tr>'
    //                    }
    //                    else if (obj[i].ChangeStatu == 2) {
    //                        s += '<tr><td>' + obj[i].EmployID + '</td><td>' + obj[i].EmployName + '</td><td>降级申请</td><td>' + obj[i].PositionName + '</td><td>' + obj[i].DeptName + '</td><td>' + obj[i].Change_time + '</td><td>' + obj[i].Change_Reason + '</td><td><input id="Button1" type="button" value="同意" onclick="funtong(' + obj[i].Situation_id + ')" /><input id="Button1" type="button" value="不同意" onclick="funbutong(' + obj[i].Situation_id + ')" /></td></tr>'
    //                    }
    //                }
    //            }
    //            s += '</tbody>'
    //            s += '</table>'
    //            $("#div").html(s);
    //        }
    //    })
    //})
    
    function funtong(id)
    {
        
        var Situation_id = id;
        $.ajax({
            url: "/ModiFication/Tong",
            data: { Situation_id: Situation_id },
            success:function(obj)
            {
                if(obj>0)
                {
                    alert('谢谢您的操作！')
                }
                else
                {
                    alert('操作失败！')
                }
            }
        })

    }
    function funbutong(id) {
      
        var Situation_id = id;
        $.ajax({
            url: "/ModiFication/BuTong",
            data: { Situation_id: Situation_id },
            success: function (obj) {
                if (obj > 0) {
                    alert('谢谢您的操作！')
                }
                else {
                    alert('操作失败！')
                }
            }
        })

    }
        
</script>
